-
Notifications
You must be signed in to change notification settings - Fork 821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NEW DBField validation #11397
NEW DBField validation #11397
Conversation
$validator->validationError( | ||
$this->name, | ||
_t('SilverStripe\\Forms\\EmailField.VALIDATION', 'Please enter an email address'), | ||
'validation' | ||
$validationResult->getMessages()[0]['message'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting the message from the $validationResult rather than simply using $message in case we want to use the special symfony strings such as {{ value }}
in the future
return $result; | ||
} | ||
|
||
public function scaffoldFormField(?string $title = null, array $params = []): ?FormField |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was copy pasted from DBVarchar, just changing the TextField to an EmailField
src/ORM/FieldType/DBField.php
Outdated
@@ -43,6 +45,10 @@ | |||
*/ | |||
abstract class DBField extends ModelData implements DBIndexable | |||
{ | |||
public function validate(): ValidationResult |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Signature matches DataObject::validate() for consistency
This method should be moved further down the class
98198a5
to
2bf5c61
Compare
2bf5c61
to
fe46daa
Compare
Closed in favor of #11402 |
Issue #11391
To share the email validation logic between the EmailField::validate() and DBEmail::validate() I've simply used the symfony email constraint
There are now 3x different validate() methods
Validator should really be renamed to FormValidator for clarify. A (Form)Validator has a ValidationResult as a property
TODO: